home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
src
/
haeberli
/
tools
/
reslist.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-08-01
|
2KB
|
70 lines
/*
* Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
* the contents of this file may not be disclosed to third parties, copied or
* duplicated in any form, in whole or in part, without the prior written
* permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to restrictions
* as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
* and Computer Software clause at DFARS 252.227-7013, and/or in similar or
* successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
* rights reserved under the Copyright Laws of the United States.
*/
#include "stdio.h"
#define BACKMAGIC (('P'<<24)+('A'<<16)+('U'<<8)+('L'<<8))
#define RESSIZE (4+4+32)
#define MAXRES (100)
char nametab[MAXRES][32];
int offsettab[MAXRES];
int lengthtab[MAXRES];
main(argc,argv)
int argc;
char **argv;
{
int i, n, pos;
FILE *inf;
long magic;
if(argc<2) {
fprintf(stderr,"usage: reslist progin\n");
exit(1);
}
inf = fopen(argv[1],"r");
if(!inf) {
fprintf(stderr,"reslist: can't open input file %s for reading\n",argv[1]);
exit(1);
}
for(i=0; i<3; i++) {
fseek(inf,-(4+i*4),SEEK_END);
magic = 5;
fread(&magic,sizeof(long),1,inf);
if(magic != BACKMAGIC) {
fprintf(stderr,"reslist: no resources found\n");
exit(1);
}
}
fseek(inf,-(4+3*4),SEEK_END);
fread(&n,sizeof(long),1,inf);
printf("\nThis file contains %d resources: \n",n);
for(i=0; i<n; i++) {
fseek(inf,-(4+3*4+4)-i*RESSIZE,SEEK_END);
fread(&lengthtab[i],sizeof(long),1,inf);
fseek(inf,-(4+3*4+4+4)-i*RESSIZE,SEEK_END);
fread(&offsettab[i],sizeof(long),1,inf);
fseek(inf,-(4+3*4+4+4+32)-i*RESSIZE,SEEK_END);
fread(nametab[i],32,1,inf);
}
for(i=0; i<n; i++) {
printf(" name: %s length %d offset %d\n",
nametab[i],lengthtab[i],offsettab[i]);
}
printf("\n");
}